/*
 * Copyright (c) 2020 hebeiyiliuba.com
 * All rights reserved.
 *
 */
package org.jeecg.modules.middleware.rabbitmq.gen.handler.impl;

import com.alibaba.fastjson.JSONObject;
import org.jeecg.modules.middleware.rabbitmq.gen.EnumGenHandler;
import org.jeecg.modules.middleware.rabbitmq.gen.handler.IGenMqHandle;
import org.jeecg.modules.wlhy.report.ShippingNoteApiAlct56Service;
import org.jeecg.modules.wlhy.report.ShippingNoteTosApiService;
import org.jeecg.modules.wlhy.shipping.entity.HyShippingNote;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * 运单接货签收-队列消息接收方法
 *
 * @author duanlikao
 * @created 2022/3/30
 */
@Service
public class ShippingDischargeHandler implements IGenMqHandle {


    private static final Logger LOGGER = LoggerFactory.getLogger(ShippingDischargeHandler.class);


    @Autowired
    private ShippingNoteApiAlct56Service shippingNoteApiAlct56Service;

    @Autowired
    private ShippingNoteTosApiService shippingNoteTosApiService;

    @Override
    public String getHandlerName() {
        return EnumGenHandler.SHIPPING_DISCHARGE.getHandlerName();
    }

    @Override
    public void handle(String channel , String msg) {

        try {
            HyShippingNote hyShippingNote =  JSONObject.parseObject(msg, HyShippingNote.class);
            if("TosApi".equals(channel) && "1".equals(hyShippingNote.getTosIdentification())  ) {
                //快货运--运单上传卸货运输节点信息
                shippingNoteTosApiService.waybillTransportDetail( hyShippingNote, "DISCHARGE");
                //快货运--签收运单同步运单轨迹
                shippingNoteTosApiService.waybillGeo(hyShippingNote);
            }
//            if("Alct56".equals(channel) && "1".equals(hyShippingNote.getAlctIdentification())){
//                //陆交开放平台 同步运单轨迹
//                shippingNoteApiAlct56Service.synTraces(hyShippingNote);
//            }
        } catch (Exception e) {
            LOGGER.error("[消费消息队列-运单收货签收-数据失败，失败信息:{}]", e.getMessage());

        }
    }
}
